<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1 id="date"></h1>
<script type="text/javascript">
    let weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];

    function getDateFull() {
        let date = new Date();//当前日期
        let year = date.getFullYear();//年
        let month = date.getMonth() + 1;//月
        let day = date.getDate();//日
        let hours = date.getHours();
        let mins = date.getMinutes();
        let secs = date.getSeconds();
        let m = hours > 12 ? "PM" : "AM";//上午 下午
        hours = hours > 12 ? hours - 12 : hours; //12小时
        let week = date.getDay();//0-6
        let str = year + "年" + month + "月" + day + "日 " + hours + ":" + mins + ":" + secs + " " + m + " " + weeks[week];
        document.getElementById("date").innerText = str;
        setTimeout("getDateFull()", 1000);//一秒后调用自己
    }

    getDateFull();
    // setInterval("getDateFull()",1000);//每隔1秒执行
</script>
</body>
</html>